package entity_controllers.cards;

import ie.FieldBoard;
import ie.PlayerBoard;
import ie.Shaker;
import entity.Account;
import entity.fields.properties.Street;
import entity_controllers.Card;
import dto.Player;
import dto.PropertyField;

public class BuildingTaxCard extends Card{
	
	private int houseTax;
	private int hotelTax;

	public BuildingTaxCard(String cardText, int houseTax, int hotelTax) {
		super(cardText);
		this.houseTax = houseTax;
		this.hotelTax = hotelTax;
	}

	@Override
	public void execute(Player player, FieldBoard fieldBoard, PlayerBoard playerBoard, Shaker shaker) {
		
		int sum = 0;
		
		PropertyField[] properties = player.getAccount().getProperties();	// Problem with using 'arrayList'
		
		for (int i = 0; i < properties.length; i++) {
			if (properties[i].getClass().equals(Street.class)) {
				int buildings = ((Street) properties[i]).getBuildings();

				if (buildings < 5)
					sum += houseTax*buildings;
				else
					sum += hotelTax;

			}
		}
		
		((Account)player.getAccount()).subBalance(sum);
		
	}
}
